﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using InvoiceInvoker.Logic;

namespace InvoiceInvoker.MvcUI.Helpers
{
	public static class ValidationHelpers
	{
		public static ValidationResult ValidateNip(string nip)
		{
			if (InvoiceInvoker.Logic.Validator.ValidateNip(nip))
			{
				return ValidationResult.Success;
			}
			else
			{
				List<string> memberNames = new List<string>();
				memberNames.Add("Nip");
				return new ValidationResult("NIP jest niepoprawny", memberNames);
			}
		}

		public static ValidationResult ValidateRegon(string regon)
		{
			if (regon == null || InvoiceInvoker.Logic.Validator.ValidateRegon(regon))
			{
				return ValidationResult.Success;
			}
			else
			{
				List<string> memberNames = new List<string>();
				memberNames.Add("Regon");
				return new ValidationResult("REGON jest niepoprawny", memberNames);
			}
		}

		public static ValidationResult ValidateInvoiceNumberFormat(string format)
		{
			if (InvoiceNumber.CheckFormat(format))
			{
				return ValidationResult.Success;
			}
			else
			{
				List<string> memberNames = new List<string>();
				memberNames.Add("InvoiceNumberFormat");
				return new ValidationResult("Format numeru faktury jest niepoprawny", memberNames);
			}
		}
	}
}